/* 
Scenic Graphics Library
Copyright (C) 2007 Jouni Tulkki

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USApackage scenic;
*/

#ifndef Scenic_Renderer_LineRenderer_h
#define Scenic_Renderer_LineRenderer_h

namespace Scenic 
{ 
namespace Renderer
{

class LineRenderer
{
	Context *context;
	
	bool isClosed;
	Double2 firstp;
	Double2 firstd;
	Double2 prevp;
	Double2 prevd;
	int count;
	int color;
	double width;
	double minu;
	double maxu;
	double miterLimit;
	bool closeStroke;
	VertexStore *vs;
	double dashLength;
	double dashPhase;

public:
	LineRenderer(Context *context, bool isClosed);

	void begin();
	void end();
	void addPoint(const Double2 &p);
private:
	void draw();
	void createEdgeTexture();
	void createDashTexture();
	void drawLine(const Double2 &p1, const Double2 &p2, const Double2 &d, double length);
	void drawCap(const Double2 &p, const Double2 &d);
	void drawSquareCap(const Double2 &p, const Double2 &d);
	void drawRoundCap(const Double2 &p, const Double2 &d);
	void drawJoin(const Double2 &p, const Double2 &d1, const Double2 &d2);
	void drawBevelJoin(const Double2 &p, const Double2 &d1, const Double2 &d2);
	void drawMiterJoin(const Double2 &p, const Double2 &d1, const Double2 &d2);
	void drawRoundJoin(const Double2 &p, const Double2 &d1, const Double2 &d2);
};

}
}

#endif
